package com.android.wellcherish.workclock.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;
import com.android.wellcherish.workclock.bean.db.Record;
import com.android.wellcherish.workclock.bean.db.RecordConstant;
import java.util.List;

/**
 * @author 张文琛
 * @date 2019/11/1 21:00
 */
@Dao
public interface RecordDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long insert(Record record);
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    List<Long> insertAll(List<Record> records);
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    List<Long> insertAll(Record... records);

    @Delete
    int delete(Record record);
    @Delete
    int deleteAll(List<Record> records);

    @Query("SELECT * FROM " + RecordConstant.TABLE_NAME)
    List<Record> queryAll();
    @Query("SELECT * FROM " + RecordConstant.TABLE_NAME
        + " WHERE " + RecordConstant.PRIMARY_TIME_COLUMN_ANME + " >= :startInclude"
        + " AND " + RecordConstant.PRIMARY_TIME_COLUMN_ANME + " < :endExclude")
    List<Record> queryByTimeInterval(long startInclude, long endExclude);

    @Update
    int update(Record record);
    @Update
    int updateAll(List<Record> records);
}
